#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 55;
int n, m;
int g[N][N];
int dp[N][N][N][N];

int main()
{
    cin >> m >> n;  
    for (int i = 1; i <= m; i ++ )
        for (int j = 1; j <= n; j ++ )
            cin >> g[i][j];

    for (int i = 1; i <= m; i ++)
        for (int j = 1; j <= n; j ++)
            for (int k = 1; k <= m; k ++)
                for (int l = 1; l <= n; l ++)
                {
                    int t1 = max(dp[i][j - 1][k][l - 1], dp[i - 1][j][k][l - 1]);
                    int t2 = max(dp[i][j - 1][k - 1][l], dp[i - 1][j][k - 1][l]);
                    if (i == k && j == l)
                        dp[i][j][k][l] = max(t1, t2) + g[i][j];
                    else
                        dp[i][j][k][l] = max(t1, t2) + g[i][j] + g[k][l];
                }


    cout << dp[m][n][m][n] << endl;
    return 0;
}